 <%-- 
    Document   : Home
    Created on : Apr 2, 2012, 8:54:57 AM
    Author     : Y.Yang
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.sql.*,java.util.*"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>UAlbanyBook</title>
        <link rel="stylesheet" type="text/css" href="default.css" />
    </head>
    <body>
    <div id="header">
    <div id="slogan">
    UAlbanyBook
    </div>
        
        
    <form name="form1" method="post" action="Search">
      <label for="Searchbar"></label><input type="text" name="Search" id="Search" size="50">
      <input type="submit" name="search" id="search" value="Search">
      
      <a id = "headerlink" href="Home.jsp">Home</a>
      <a id = "headerlink" href="Profile.jsp">My Profile</a>
      <a id="w"><% if(session.getAttribute("user")== null){
                        response.sendRedirect("Home.jsp");
                    }
                    else
                       out.println("Welcome " +session.getAttribute("user")+"!");%></a>
      <a id = "headerlink" href="index.jsp">Sign out</a>
   </form> 
    </div>
   
    <div id = "menu">
      <p align="left"><a href="profileBasicInfo.jsp">Basic Information</a></p>
      <p align="left">&nbsp;</p>
      <p align="left"><a href="profilePicture.jsp">Profile Picture</a></p>
      <p align="left">&nbsp;</p>
      <p align="left"><a href="profileeduandwork.jsp">Education and Work</a></p>
      <p align="left">&nbsp;</p>
      <p align="left"><a href="profileArtandEnt.jsp">Arts and Entertainment</a></p>
      <p align="left">&nbsp;</p>
      <p align="left"><a href="profileWishlist.jsp">Wish List</a>      </p>
      <p align="left">&nbsp;</p>
      <p align="left"><a href="profileContact.jsp">Contact Information</a></p>
      <p align="left">&nbsp;</p>
</div>
    
    
    <div id = "profile">
     <%
        String URL = "jdbc:mysql://localhost:3306/ualbanybook";
        String USERNAME = "root";
        String PASSWORD = "isaac16";
        Connection connection = null;
        PreparedStatement statement = null;
        ResultSet rstLogin = null;
        //HttpSession session = new HttpSession();
        
        try
        {
            Class.forName("com.mysql.jdbc.Driver");
            connection = DriverManager.getConnection(URL, USERNAME, PASSWORD);
            
            statement = connection.prepareStatement("SELECT * FROM useraccount WHERE Email = ?");
            statement.setString(1, (String)session.getAttribute("email"));
            rstLogin = statement.executeQuery();
            while(rstLogin.next())
            {%>
  
            
            <form name="formBasicInfo" method="post" action="">
    <p align="center"><strong>Basic Information</strong></p>
    <p><span style="padding-left: 90px">First Name:</span>
        <input type="text" name="Hometown5" id="Hometown5" value="<%out.println(rstLogin.getString("firstName"));%>">
    </p>
    <p><span style="padding-left: 90px">Last Name:</span>
        <input type="text" name="Hometown5" id="Hometown6" value="<%out.println(rstLogin.getString("lastName"));%>">
    </p>
    <p><span style="padding-left: 90px">Email:</span>
        <input type="text" name="Hometown5" id="Hometown7" value="<%out.println(rstLogin.getString("Email"));%>">
    </p>
    <p><span style="padding-left: 90px">Hometown:</span>
        <input type="text" name="Hometown5" id="Hometown8" value="<%out.println(rstLogin.getString("hometown"));%>">
    </p>
    <p>&nbsp;</p>
    <p><span style="padding-left: 90px">I am:</span>
      <input type="text" name="Hometown5" id="Hometown8" value="<%out.println(rstLogin.getString("sex"));%>">
    </p>
    <p>&nbsp;</p>
    <p><span style="padding-left: 90px">Birthday:</span>
      <select name="SignupSex5" id="SignupSex5">
        <option value="Jan">Jan</option>
        <option value="Feb">Feb</option>
        <option value="Mar">Mar</option>
        <option value="Apr">Apr</option>
        <option value="May">May</option>
        <option value="Jun">Jun</option>
        <option value="Jul">Jul</option>
        <option value="Aug">Aug</option>
        <option value="Sep">Sep</option>
        <option value="Oct">Oct</option>
        <option value="Nov">Nov</option>
        <option value="Dev">Dev</option>
      </select>
      <select name="SignupSex5" id="SignupSex6">
        <option value="1">1</option>
        <option value="2">2</option>
        <option value="3">3</option>
        <option value="4">4</option>
        <option value="5">5</option>
        <option value="6">6</option>
        <option value="7">7</option>
        <option value="8">8</option>
        <option value="9">9</option>
        <option value="10">10</option>
        <option value="11">11</option>
        <option value="12">12</option>
        <option value="13">13</option>
        <option value="14">14</option>
        <option value="15">15</option>
        <option value="16">16</option>
        <option value="17">17</option>
        <option value="18">18</option>
        <option value="19">19</option>
        <option value="20">20</option>
        <option value="21">21</option>
        <option value="22">22</option>
        <option value="23">23</option>
        <option value="24">24</option>
        <option value="25">25</option>
        <option value="26">26</option>
        <option value="27">27</option>
        <option value="28">28</option>
        <option value="29">29</option>
        <option value="30">30</option>
        <option value="31">31</option>
      </select>
      <select name="SignupSex5" id="SignupSex7">
        <option value="2012">2012</option>
        <option value="2011">2011</option>
        <option value="2010">2010</option>
        <option value="2009">2009</option>
        <option value="2008">2008</option>
        <option value="2007">2007</option>
        <option value="2006">2006</option>
        <option value="2005">2005</option>
        <option value="2004">2004</option>
        <option value="2003">2003</option>
        <option value="2002">2002</option>
        <option value="2001">2001</option>
        <option value="1999">1999</option>
        <option value="1998">1998</option>
        <option value="1997">1997</option>
        <option value="1996">1996</option>
        <option value="1995">1995</option>
        <option value="1994">1994</option>
        <option value="1993">1993</option>
        <option value="1992">1992</option>
        <option value="1991">1991</option>
        <option value="1990">1990</option>
        <option value="1989">1989</option>
        <option value="1988">1988</option>
        <option value="1987">1987</option>
        <option value="1986">1986</option>
        <option value="1985">1985</option>
        <option value="1984">1984</option>
        <option value="1983">1983</option>
        <option value="1982">1982</option>
        <option value="1981">1981</option>
      </select>
    </p>
    <p>&nbsp;</p>
    <p><span style="padding-left: 90px">About me:</span>
      <textarea name="About me2" id="Aboutme2" cols="45" rows="5"><%out.println(rstLogin.getString("aboutme"));%></textarea>
    </p>
    </form>
      <%}%>
    <%
      }
        catch(ClassNotFoundException e){
        out.println("Couldn't load database driver: " + e.getMessage());
        }
        catch (SQLException sqlException){
            out.println(sqlException.getMessage());
            
        }  
        finally {            
            try{
                if(connection != null)
                    connection.close();
                if(rstLogin != null)
                    rstLogin.close();
            }
            catch(SQLException ignored){
            out.println(ignored.getMessage()); 
            }
        }
        %>
    
    <form id="formUpdateBasic" method="post" action ="UpdateBasicInfo">
        <p align="center">&nbsp;</p>
    <p align="center">&nbsp;</p>
    <p><span style="padding-left: 90px">First Name:</span>
      <input type="text" name="updatefistName" id="Hometown2">
</p>
    <p><span style="padding-left: 90px">Last Name:</span>
      <input type="text" name="updatelastName" id="Hometown3">
    </p>
    <p>&nbsp;</p>
    <p><span style="padding-left: 90px">Hometown:</span> 
      <input type="text" name="updateHometown" id="Hometown">
    </p>
    <p>&nbsp;</p>
    <p><span style="padding-left: 90px">I am:</span>
      <label for="SignupSex"></label>
      <select name="updateSex" id="SignupSex">
        <option value="Female">Female</option>
        <option value="Male">Male</option>
      </select>
    </p>
    <p>&nbsp;</p>
    <p><span style="padding-left: 90px">Birthday:</span>
      <select name="SignupSex2" id="SignupSex2">
        <option value="Jan">Jan</option>
        <option value="Feb">Feb</option>
        <option value="Mar">Mar</option>
        <option value="Apr">Apr</option>
        <option value="May">May</option>
        <option value="Jun">Jun</option>
        <option value="Jul">Jul</option>
        <option value="Aug">Aug</option>
        <option value="Sep">Sep</option>
        <option value="Oct">Oct</option>
        <option value="Nov">Nov</option>
        <option value="Dev">Dev</option>
      </select>
      <select name="SignupSex3" id="SignupSex3">
        <option value="1">1</option>
        <option value="2">2</option>
        <option value="3">3</option>
        <option value="4">4</option>
        <option value="5">5</option>
        <option value="6">6</option>
        <option value="7">7</option>
        <option value="8">8</option>
        <option value="9">9</option>
        <option value="10">10</option>
        <option value="11">11</option>
        <option value="12">12</option>
        <option value="13">13</option>
        <option value="14">14</option>
        <option value="15">15</option>
        <option value="16">16</option>
        <option value="17">17</option>
        <option value="18">18</option>
        <option value="19">19</option>
        <option value="20">20</option>
        <option value="21">21</option>
        <option value="22">22</option>
        <option value="23">23</option>
        <option value="24">24</option>
        <option value="25">25</option>
        <option value="26">26</option>
        <option value="27">27</option>
        <option value="28">28</option>
        <option value="29">29</option>
        <option value="30">30</option>
        <option value="31">31</option>
      </select> 
      <select name="SignupSex4" id="SignupSex4">
        <option value="2012">2012</option>
        <option value="2011">2011</option>
        <option value="2010">2010</option>
        <option value="2009">2009</option>
        <option value="2008">2008</option>
        <option value="2007">2007</option>
        <option value="2006">2006</option>
        <option value="2005">2005</option>
        <option value="2004">2004</option>
        <option value="2003">2003</option>
        <option value="2002">2002</option>
        <option value="2001">2001</option>
        <option value="1999">1999</option>
        <option value="1998">1998</option>
        <option value="1997">1997</option>
        <option value="1996">1996</option>
        <option value="1995">1995</option>
        <option value="1994">1994</option>
        <option value="1993">1993</option>
        <option value="1992">1992</option>
        <option value="1991">1991</option>
        <option value="1990">1990</option>
        <option value="1989">1989</option>
        <option value="1988">1988</option>
        <option value="1987">1987</option>
        <option value="1986">1986</option>
        <option value="1985">1985</option>
        <option value="1984">1984</option>
        <option value="1983">1983</option>
        <option value="1982">1982</option>
        <option value="1981">1981</option>
      </select>
    </p>
    <p>&nbsp;</p>
    <p><span style="padding-left: 90px">About me:</span>
      <textarea name="updateAboutme" id="Aboutme" cols="45" rows="5"></textarea>
    </p>
    <p>
      <label for="Aboutme"></label>
    </p>    
    <p>
      <span style="padding-left: 80px"><input type="submit" name="Signup" id="Signup2" value="Save Changes"></span>
  </p>
    </form>
       </div>
    
    
    
      
    <p>&nbsp;</p>
    </body>
</html>
